<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>密码申请</title>
<link rel="stylesheet" type="text/css" href="themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="themes/icon.css">
<link rel="stylesheet" type="text/css" href="resources/css/demo.css">
<script type="text/javascript" src="resources/js/jquery.min.js"></script>
<script type="text/javascript" src="resources/js/jquery.easyui.min.js"></script>
</head>
<body>
	<div class="easyui-panel" title="密码生成" style="width:100%;max-width:400px;padding:30px 60px;">
		<form id="ff" method="post">
			<div style="margin-bottom:20px">
				<label class="textbox-label textbox-label-left" for="_easyui_textbox_input5" style="text-align: left; height: 25px; line-height: 25px;">申请类别:</label>
				<span id="ptypeSpan" class="radioSpan">
	                <input type="radio" name="ptype" value="0" checked="checked">shell</input>
	                <input type="radio" name="ptype" value="1">root</input>
	            </span>
			</div>
			<div style="margin-bottom:20px">
				<input class="easyui-datebox" name="rdate" labelPosition="left" style="width: 100%;" data-options="label:'申请日期:',required:true,formatter:myformatter,parser:myparser">
			</div>
			<div style="margin-bottom:20px">
				<input class="easyui-textbox" name="email" style="width:100%" data-options="label:'SN',required:true">
			</div>
		</form>
		<div style="text-align:center;padding:5px 0">
			<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:submitForm()" style="width:80px">提交</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">清空</a>
		</div>
	</div>
</body>
<script type="text/javascript">
	function myformatter(date){
		var y = date.getFullYear();
		var m = date.getMonth()+1;
		var d = date.getDate();
		return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
	}

	function myparser(s){
		if (!s) return new Date();
		var ss = (s.split('-'));
		var y = parseInt(ss[0],10);
		var m = parseInt(ss[1],10);
		var d = parseInt(ss[2],10);
		if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
			return new Date(y,m-1,d);
		} else {
			return new Date();
		}
	}
	
	function submitForm(){
		var ptypeVal = $('#ptypeSpan input[name="ptype"]:checked').val();
		if(ptypeVal == 0) {
			requestShellPasswd();
		}else {
			requestRootPasswod();
		}
	}
		
	function requestShellPasswd() {
		$.ajax({
			url		: "passwd/shell",
			type	: "GET",
			data	: {
				sn		:123456,
				rtime	:20180331
			},
			sucess	: function (data) {
				alert(data);
			},
			dataType:"text",
			error	: function(data) {
				alert("error");
			}
		});
		
	}
	
	function requestRootPasswod() {
		$.ajax({
			url		: "passwd/root",
			type	: "GET",
			data	: {
				sn		:123456,
			},
			sucess	: function (data) {
				alert(data);
			},
			dataType:"text",
			error	: function(data) {
				alert("error");
			}
		});
	}
	
	
</script>
</html>